package com.azzcs.userservicealibaba.config;

import com.alibaba.druid.pool.DruidDataSource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import javax.sql.DataSource;

/**
 * @Author: wzg
 * @Date: 2021/2/24 下午2:21
 */
@Slf4j
@RefreshScope
@Configuration
public class DataSourceConfig {


    @Bean
    @Primary
    @RefreshScope
    @ConfigurationProperties(prefix = "spring.datasource")
    public DruidDataSource druidDataSource(){
        log.info("update druidDataSource");
        return new DruidDataSource();
    }
}
